<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
    *{margin:0;padding:0;}
    #parent>div{
        width:200px;
        height:100px;
        border:1px solid #333;
        float: left;
    }
    #parent{
        margin-left: auto;
        margin-right: auto;
        overflow: hidden;
    }
    </style>
</head>
<body>
    <div id="parent">
        <div id="child"></div>
        <div></div>
        <div></div>
        <div></div>
    </div>
    <script>
    var parent=document.getElementById("parent");
    var childwidth=document.getElementById("child").offsetWidth;
    parent.style.width=childwidth*4+"px";
    </script>
</body>
</html>